<extend name="_layout/main"/>
<block name="head">
    <style>
        #pay_type {
            margin: 0;
            padding: 0;
            width: 80%;
        }
    </style>
</block>
<block name="top">
    <header class="mui-bar mui-bar1 mui-bar-nav mui-bar-nav1" id="header">
        <a class="btn" href="javascript:history.go(-1)">
            <i class="iconfont icon-fanhui"></i>
        </a>
        <div class="top-sch-box top-sch-boxtwo top-sch-boxthree flex-col">
            返回
        </div>
    </header>
</block>
<block name="content">
    <form name="applyForm" id="applyForm" action="{:U('apply_active')}">
        <div class="warp warpthree clearfloat">
            <include file="_layout/member_head"/>
            <div class="apply clearfloat">
                <div class="bottom clearfloat">
                    <ul>
                        <li>
                            <div class="box-s clearfloat">
                                <p>报单金额：</p>
                                <input type="text" id="amount" name="amount" value=""
                                       placeholder="报单金额，最低￥{$setting.min_user_active_amount}"/>
                            </div>
                        </li>
                        <li>
                            <div class="box-s clearfloat">
                                <p>对方账户：</p>
                                <input type="text" id="username" name="username" value="" placeholder="要激活账户ID/手机号"/>
                            </div>
                        </li>

                        <li>
                            <div class="box-s clearfloat">
                                <p>支付方式：</p>
                                <select name="pay_type" id="pay_type">
                                    <option value="1">全部现金</option>
                                    <option value="2">
                                        {$setting.pay_balance_percent}%现金+{$setting.pay_integral_percent}%积分
                                    </option>
                                </select>
                            </div>
                        </li>
                    </ul>
                </div>

                <a href="javascript:void(0)" class="center-btn db ra3" id="btn-save">提交</a>
            </div>
        </div>
    </form>
    <div class="recharge clearfloat">
        <div class="guize clearfloat box-s ra3">
            <h3>报单规则</h3>
            <div class="content clearfloat">
                {$setting.active_user_annouce|stripslashes|htmlspecialchars_decode}
            </div>
        </div>
    </div>
</block>
<block name="scripts">
    <script type="text/javascript" src="__JS__/jquery.form.js"></script>
    <script>
        $(document).on('click', '#btn-save', function (e) {
            e.preventDefault();
            var form = $("#applyForm");
            if (!form.is('form')) {
                return;
            }
            var action = form.attr("action");
            var data = form.serialize();

            var username = $('#username').val();
            if(!username || username == ''){
                mui.alert('请输入对方ID/手机号');
                return;
            }
            var amount = $('#amount').val();
            var amount_min = $('#amount').data('min');
            if(!amount || amount < amount_min){
                mui.alert('请输入合适的金额,最低'+amount_min);
                return;
            }

            if (action && data) {
                mui.confirm('确认提交用户【' + $('#username').val() + '】激活申请', '提示', ['确定', '取消'], function (obj) {
                    if (obj.index == 0) {
                        $.post(action, data, function (xdata) {
                            if (xdata.status == 'success') {
                                form[0].reset();
                                mui.alert(xdata.message, '提示',function () {
                                    document.location.href = xdata.data.url;
                                });
                            } else {
                                mui.alert(xdata.message, '错误提示');
                            }
                        }, 'json');
                    }
                });
            }
        })

    </script>
</block>